import Vue from 'vue'
import Router from 'vue-router'
import Test from '@/components/Test'
import Login from '@/components/Login'
import Home from '@/components/Home'
import Reg from '@/components/Reg'
import Category from '@/components/Category.vue'
import Cart from '@/components/Cart.vue'
import Mine from '@/components/Mine.vue'
import GoodsDetail from '@/components/GoodsDetail.vue'
import AddressManage from '@/components/AddressManage.vue'
import AddressManageAdd from '@/components/AddressManageAdd.vue'
import AddressManageEdit from '@/components/AddressManageEdit.vue'
import Orders from '@/components/Orders.vue'
import Settle from '@/components/Settle.vue'
import PersonalInfo from '@/components/PersonalInfo.vue'
import Checkstand from '@/components/Checkstand.vue'
import MyWallet from '@/components/MyWallet.vue'
import SearchPage from '@/components/SearchPage.vue'
import ModifyPassword from '@/components/ModifyPassword.vue'
import CommentProduct from '@/components/CommentProduct.vue'
import FindPassword from '@/components/FindPassword.vue'
import MyPartner from '@/components/MyPartner.vue'
import BankInfo from '@/components/BankInfo.vue'
import RemainingSumDetail from '@/components/RemainingSumDetail.vue'
import RewardDetail from '@/components/RewardDetail.vue'
import AboutUs from '@/components/AboutUs.vue'
import WithDrawCash from '@/components/WithDrawCash.vue'
import RecommendErWeiMa from '@/components/RecommendErWeiMa.vue'
import GuanZhuErWeiMa from '@/components/GuanZhuErWeiMa.vue'
import GuanZhuErWeiMa2 from '@/components/GuanZhuErWeiMa2.vue'
import yonghuxieyi from '@/components/yonghuxieyi.vue'
import Logistics from '@/components/Logistics.vue'
Vue.use(Router)

export default new Router({
	mode: 'history',
	routes: [{
			path: '/wx/test',
			name: 'Test',
			component: Test
		},
		{
			path: '/wx/login',
			name: 'Login',
			component: Login
		},
		{
			path: '/wx/home',
			name: 'Home',
			component: Home
		},
//		{
//			path: '/*',
//			redirect: '/wx/home'
//		},
		{
			path: '/wx/',
			redirect: '/home'
		},
		{
			path: '/wx/register',
			name: 'Reg',
			component: Reg
		},
		{
			path: '/wx/category',
			name: 'Category',
			component: Category
		},
		{
			path: '/wx/category/:id',
			name: 'Category',
			component: Category
		},
		{
			path: '/wx/cart',
			name: 'Cart',
			component: Cart,
			beforeEnter: (to, from, next) => {
				from.path == '/wx/checkstand'? next('/wx/cart') : next()
			}
		},
		{
			path: '/wx/mine',
			name: 'Mine',
			component: Mine
		},
		{
			path: '/wx/detail',
			name: 'Detail',
			component: GoodsDetail
		},
		{
			path: '/wx/detail/:id',
			name: 'Detail',
			component: GoodsDetail
		},
		{
			path: '/wx/address',
			name: 'AddressManage',
			component: AddressManage
		},
		{
			path: '/wx/addressAdd',
			name: 'AddressManageAdd',
			component: AddressManageAdd
		},
		{
			path: '/wx/addressEdit',
			name: 'AddressManageEdit',
			component: AddressManageEdit
		},
		{
			path: '/wx/orders',
			name: 'Orders',
			component: Orders
		},
		{
			path: '/wx/settle',
			name: 'Settle',
			component: Settle,
			beforeEnter: (to, from, next) => {
				from.path == '/wx/checkstand'? next('/wx/cart') : next()
				from.path == '/wx/cart'? next() : next('/wx/home')
			}
		},
		{
			path: '/wx/personalInfo',
			name: 'PersonalInfo',
			component: PersonalInfo
		},
		{
			path: '/wx/checkstand',
			name: 'Checkstand',
			component: Checkstand,
			beforeEnter: (to, from, next) => {
				from.path == '/wx/settle'||from.path == '/wx/orders'? next() : next('/wx/home')
			}
		},
		{
			path: '/wx/myWallet',
			name: 'MyWallet',
			component: MyWallet
		},
		{
			path: '/wx/searchPage',
			name: 'SearchPage',
			component: SearchPage
		},
		{
			path: '/wx/modifyPassword',
			name: 'ModifyPassword',
			component: ModifyPassword
		},
		{
			path: '/wx/commentProduct',
			name: 'CommentProduct',
			component: CommentProduct
		},
		{
			path: '/wx/findPassword',
			name: 'FindPassword',
			component: FindPassword
		},
		{
			path: '/wx/myPartner',
			name: 'MyPartner',
			component: MyPartner
		},
		{
			path: '/wx/bankInfo',
			name: 'BankInfo',
			component: BankInfo
		},
		{
			path: '/wx/remainingSumDetail',
			name: 'RemainingSumDetail',
			component: RemainingSumDetail
		},
		
		{
			path: '/wx/rewardDetail',
			name: 'RewardDetail',
			component: RewardDetail
		},
		{
			path: '/wx/aboutUs',
			name: 'AboutUs',
			component: AboutUs
		},
		{
			path: '/wx/withDrawCash',
			name: 'WithDrawCash',
			component: WithDrawCash
		},
		{
			path: '/wx/recommendErWeiMa',
			name: 'RecommendErWeiMa',
			component: RecommendErWeiMa
		},
		{
			path: '/wx/guanZhuErWeiMa',
			name: 'GuanZhuErWeiMa',
			component: GuanZhuErWeiMa
		},
		{
			path: '/wx/guanZhuErWeiMa2',
			name: 'GuanZhuErWeiMa2',
			component: GuanZhuErWeiMa2
		},
		{
			path: '/wx/yonghuxieyi',
			name: 'yonghuxieyi',
			component: yonghuxieyi
		},
		{
			path: '/wx/logistics',
			name: 'Logistics',
			component: Logistics
		},
	]
})